###各國家計算腳本，繼承自西語通用計算類

import json
import os

from feature_set.app.un.app_un_gcate_v1.AppUnGCateV1 import AppUnGCateV1


class AppIdGCateV1(AppUnGCateV1):
    def __init__(self):
        super().__init__()
        ###各國家的配置信息
        ###各國家app解析後對應的字段名
        self.country_info = json.load(
            open(
                os.path.join(
                    self.conf_dir,
                    "app",
                    "id",
                    "app_id_gcate_v1",
                    "app_id_gcate_v1_country_info.json",
                )
            )
        )
        ##配置google爬取的app信息
        self.google_info_dic = json.load(
            open(
                os.path.join(
                    self.conf_dir, "app", "id", "app_id_gcate_v1", "google_info.json"
                )
            )
        )
        self.app_name = "app_name"
        self.package_name = "app_package"
        self.inst_time_name = "fi_time"
        self.updt_time_name = "lu_time"
        self.pre_inst_name = "isSystem"

    def mark_pre_inst_tag(self):
        for app in self.app_list:
            if app["inst_time"] <= self.pre_inst_time_boundary:
                app["preinst_tag"] = 1
            else:
                app["preinst_tag"] = 0
